# -*- coding: utf-8 -*-
"""
@Time ： 2024/5/8 16:01
@Auth ： 李天天
"""
import random
import time

import requests

from Common.basepage import BasePage
# from Common.handle_redis import RedisHelper
from PageObjects.Main_page import MainPage
from PageObjects.Player_page import PlayerPage

# do_redis = RedisHelper(host="116.62.245.174", port="6379", password="li123456")


def start_invite():
    BasePage("d_one").start_middleware_app()
    time.sleep(2)
    # MainPage("d_one").click_AV()
    # time.sleep(1)
    MainPage("d_one").click_SynPlay()
    time.sleep(2)
    MainPage("d_one").click_share()
    time.sleep(3)
    MainPage("d_one").click_slave_invite()
    time.sleep(2)
    MainPage("d_one").click_point(0.4, 0.5, img_desc="点击空白处返回")


def back_to_main():
    MainPage("d_one").click_back()


def press_invite():
    while True:
        start_invite()
        time.sleep(10)
        back_to_main()
        time.sleep(2)


if __name__ == '__main__':
    # do_redis.set(key="stop_HQ", value="False", ex="86400")
    # while True:
    #     if not eval(do_redis.get(key="stop_HQ")):
    #         try:
    #             press_invite()
    #         except:
    #             BasePage("d_one").press_key("back")
    #             time.sleep(1)
    #             BasePage("d_one").press_key("back")
    #             # BasePage("d_one").click_point(0.08, 0.509, "点击空白处返回")
    #             # back_to_main()
    #             # requests.get(url="https://api.day.app/s3KoLFVvWVWdYiiro2gKW/多屏1.0自动操作脚本可能出现问题")
    #     else:
    #         break
    while True:
        try:
            press_invite()
        except:
            BasePage("d_one").press_key("back")
            time.sleep(1)
            BasePage("d_one").press_key("back")
